package com.lsa.letcode.the11.containerMostWater;

public class Solution {
    public int maxArea(int[] height) {
    	if (height == null || height.length == 0) {
    		return 0;
    	}
    	int maxArea = 0;
    	
    	int i = 0; 
    	int j = height.length - 1;
    	
    	while(i < j) {
    		int minHeight = Math.min(height[i], height[j]);
    		maxArea = Math.max(maxArea, minHeight * (j - i));
    		
    		if (height[i] < height[j]) {
    			i++;
    		}
    		else {
    			j--;
    		}
    	}

    	return maxArea;
    }
}